import { defineStore } from 'pinia'
import { simpleData } from '../API/echartsAPI'

export const useEcharts = defineStore('echartStore',{
    state:() => {
        return {
            echartList:[],
            xList:[],
            series:[]
        }
    },
    getters:{

    },
    actions:{
        // 获取图表数据
        async handleEcharts() {
            const res = await simpleData()
            this.echartList = res.data.map(item => {return {value:item.val,name:item.x}})
            this.xList = res.data.map(item => item.x)
            this.series = res.data.map(item => item.val)
        }
    }
})